/*
 * author: qinjinpeng
 * common.js
 */

function is_mobile(){
	if(/AppleWebKit.*Mobile/i.test(navigator.userAgent) || /Android|Windows Phone|webOS|iPhone|iPod|BlackBerry/i.test(navigator.userAgent)){
		return true;
	}
	return false;
}
var is_mobile = is_mobile();

function homepage(){
	var url = "http://"+document.domain;
	if (document.all){
		document.body.style.behavior='url(#default#homepage)';
		document.body.setHomePage(url);
	}else if (window.sidebar){
		if(window.netscape){
			try{ 
				netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); 
			}catch (e){ 
				alert( "该操作被浏览器拒绝，如果想启用该功能，请在地址栏内输入 about:config,然后将项 signed.applets.codebase_principal_support 值该为true" ); 
			}
		}
		var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components. interfaces.nsIPrefBranch);
		prefs.setCharPref('browser.startup.homepage',url);
	}else{
		alert('您的浏览器不支持自动设置首页, 请使用浏览器菜单手动设置!');
	}
}
$(document).on("click", ".homepage", homepage);

//加入收藏
function favorite(){
	var url = "http://"+document.domain;
	if (document.all){
		window.external.addFavorite(url,document.title);
	}else if (window.sidebar){
		window.sidebar.addPanel(document.title, url, "");
	}else{
		alert("加入收藏失败，请使用Ctrl+D进行添加");
	}
}
$(document).on("click", ".favorite", favorite);



